package cn.tedu.banner.management.dao.perisit.repository.impl;


import cn.tedu.banner.management.dao.perisit.mapper.BannerMapper;
import cn.tedu.banner.management.dao.perisit.repository.IBannerRepository;

import cn.tedu.banner.management.pojo.entity.Banner;
import cn.tedu.banner.management.pojo.param.BannerParam;
import cn.tedu.banner.management.pojo.vo.BannerAdminVO;
import cn.tedu.banner.management.pojo.vo.BannerIndexVO;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;

import java.util.List;

@Slf4j
@Repository
public class BannerRepositoryImpl implements IBannerRepository {

    @Autowired
    private BannerMapper bannerMapper;

    @Override
    public Banner selectBySort(Integer sort) {
        return bannerMapper.selectBySort(sort);
    }

    @Override
    public int avatar(Banner banner) {
        return bannerMapper.avatar(banner);
    }

    //添加轮播图
    @Override
    public int insert(Banner banner) {
        return bannerMapper.insert(banner);
    }

    //删除轮播图
    @Override
    public int deleteById(Long id) {
        return bannerMapper.deleteById(id);
    }

    //用户首页轮播图展示
    @Override
    public List<BannerIndexVO> selectForIndex() {
        return bannerMapper.selectForIndex();
    }

    //管理员轮播图列表
    @Override
    public List<BannerAdminVO> selectForAdmin() {
        return bannerMapper.selectForAdmin();
    }

    @Override
    public Banner count(Long id) {
        Banner banner = bannerMapper.selectById(id);
        return banner;
    }
}
